#ifndef __TASKQUEUE_H_
#define __TASKQUEUE_H_

#include "Task.hpp"
#include "Noncopyable.hpp"
#include "Condition.hpp"
#include "MutexLock.hpp"
#include <queue>

using std::queue;
using std::size_t;

namespace tp{

using ElemType = tp::Task *;

class TaskQueue
:Noncopyable
{
public:
    TaskQueue(size_t);
    ~TaskQueue();
    bool empty() const;
    bool full() const;
    void push(ElemType);
    ElemType pop();

    void wakeup();//唤醒所有子线程

private:
    queue<ElemType> _que;
    size_t          _queSize;
    MutexLock       _mutex;
    Condition       _notFull;
    Condition       _notEmpty;
    bool            _flag;//标志工作线程被全部唤醒跳出while循环
};

}//end of namespace tp

#endif

